package com.apes.fn.server.workDesk.model;

import com.apes.fn.tms.model.Site;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.party.model.PartyRole;
import com.apes.scm.rbac.model.User;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = WorkDeskUserCount.CONST_TABLE_NAME)
public class WorkDeskUserCount extends Model {

    public static final String CONST_TABLE_NAME = "WORK_DESK_USE_COUNT";

    @Id
    @Column(name = "id", nullable = false, length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "工作台数据埋点编码", padding = 12)
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    @Comment("使用用户")
    private User useUser;

    @Temporal(TemporalType.DATE)
    @Column(name = "use_date")
    @Comment("使用日期")
    private Date useDate;

    @Column(name = "use_count")
    @Comment("使用次数")
    private Integer useCount;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "WORK_DESK_CONFIG_ID", referencedColumnName = "id")
    @Comment("使用功能")
    private WorkDeskConfig useWorkDeskFunction;
}
